/*
 * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <gtest/gtest.h>

#include "sle_error_code.h"
#include "sle_seek_stub.h"
#include "sle_seek_callback_stub.h"

class SleSeekStubTest : public testing::Test {
public:
    static void SetUpTestCase();
    static void TearDownTestCase();
    void SetUp() override;
    void TearDown() override;

};
void SleSeekStubTest::SetUp()
{
}

void SleSeekStubTest::TearDown()
{
}

void SleSeekStubTest::SetUpTestCase()
{
}

void SleSeekStubTest::TearDownTestCase()
{
}

namespace OHOS {
namespace NearLink {
namespace SleStandard {

class SleSeekStubMock : public SleSeekStub {
    public:
        SleErrorCode RegisterSeekCallback(const sptr<ISleSeekCallback> &callback)
        {
            return SLE_NO_ERROR;
        }
        SleErrorCode UnregisterSeekCallback(const sptr<ISleSeekCallback> &callback)
        {
            return SLE_NO_ERROR;
        }
        SleErrorCode StartSeek(SeekParam &param)
        {
            return SLE_NO_ERROR;
        }
        SleErrorCode StopSeek()
        {
            return SLE_NO_ERROR;
        }
};

class SleSeekCallbackStubMock : public SleSeekCallbackStub {
    public:
        void OnSeekStateChange(int32_t state)
        {

        }
        void OnSeekResult(SeekResult &result)
        {

        }
};

/************************************************communication/nearlink/sle/sle_standard/frameworks/ipc/source******************************************************** */
HWTEST_F(SleSeekStubTest, OnSeekStateChangeInner_201, testing::ext::TestSize.Level0)
{
    SleSeekCallbackStubMock ssapClient;
    MessageParcel data;
    MessageParcel reply;
    MessageOption option;
    data.WriteInterfaceToken(SleSeekCallbackStub::GetDescriptor());

    data.WriteInt32(1);
    EXPECT_EQ(ssapClient.OnRemoteRequest(SLE_CALLBACK_SEEK_STATE_CHANGE, data, reply, option), NO_ERROR);
}

HWTEST_F(SleSeekStubTest, OnSeekResultInner_201, testing::ext::TestSize.Level0)
{
    SleSeekCallbackStubMock ssapClient;
    MessageParcel data;
    MessageParcel reply;
    MessageOption option;
    data.WriteInterfaceToken(SleSeekCallbackStub::GetDescriptor());

    SeekResult result;
    data.WriteParcelable(&result);
    EXPECT_EQ(ssapClient.OnRemoteRequest(SLE_CALLBACK_SEEK_RESULT, data, reply, option), NO_ERROR);
}

/************************************************communication/nearlink/sle/sle_standard/services/ipc******************************************************** */

HWTEST_F(SleSeekStubTest, RegisterSsapClientInner_001, testing::ext::TestSize.Level0)
{
    SleSeekStubMock ssapClient;
    MessageParcel data;
    MessageParcel reply;
    MessageOption option;
    data.WriteInterfaceToken(SleSeekStub::GetDescriptor());

    sptr<IRemoteObject> remoteObject = new SleSeekCallbackStubMock();
    data.WriteRemoteObject(remoteObject);

    EXPECT_EQ(ssapClient.OnRemoteRequest(SLE_REGISTER_SEEK_CALLBACK, data, reply, option), NO_ERROR);
}

HWTEST_F(SleSeekStubTest, UnregisterSeekCallbackInner_001, testing::ext::TestSize.Level0)
{
    SleSeekStubMock ssapClient;
    MessageParcel data;
    MessageParcel reply;
    MessageOption option;
    data.WriteInterfaceToken(SleSeekStub::GetDescriptor());

    sptr<IRemoteObject> remoteObject = new SleSeekCallbackStubMock();
    data.WriteRemoteObject(remoteObject);

    EXPECT_EQ(ssapClient.OnRemoteRequest(SLE_UNREGISTER_SEEK_CALLBACK, data, reply, option), NO_ERROR);
}


HWTEST_F(SleSeekStubTest, StartSeekInner_001, testing::ext::TestSize.Level0)
{
    SleSeekStubMock ssapClient;
    MessageParcel data;
    MessageParcel reply;
    MessageOption option;
    data.WriteInterfaceToken(SleSeekStub::GetDescriptor());

    SeekParam param;
    data.WriteParcelable(&param);

    EXPECT_EQ(ssapClient.OnRemoteRequest(SLE_SEEK_ENABLE, data, reply, option), NO_ERROR);
}

HWTEST_F(SleSeekStubTest, StopSeekInner_001, testing::ext::TestSize.Level0)
{
    SleSeekStubMock ssapClient;
    MessageParcel data;
    MessageParcel reply;
    MessageOption option;
    data.WriteInterfaceToken(SleSeekStub::GetDescriptor());

    EXPECT_EQ(ssapClient.OnRemoteRequest(SLE_SEEK_DISABLE, data, reply, option), NO_ERROR);
}



}}}